package com.buercorp.wangyu.core1.ch12.threads.threadsPool;

import java.util.concurrent.Callable;

public class MyCallable implements Callable {
    private int n;

    public MyCallable(int n) {
        this.n = n;
    }

    @Override
    public Object call() throws Exception {
        // 需求 求 1-n的和返回
        int sum = 0;
        for (int i = 1; i < n; i++) {
            sum += i;
        }
        return Thread.currentThread().getName() + " 求出1到" + n + "的和是：" + sum;
    }
}
